<template>
  <div>

  </div>
</template>

<script setup>
import {onMounted} from 'vue';
import api from "@/api";
import {useRoute} from "vue-router";

const route = useRoute();

onMounted(async () => {
  try {
    const resp = await api.get(`/alipay/pay?orderNo=${route.query.id}&amount=${route.query.amount}`);
    // 创建一个临时的 div 元素
    const tempDiv = document.createElement('div');
    tempDiv.innerHTML = resp.data;
    // 将临时 div 元素添加到 body 中
    document.body.appendChild(tempDiv);
    // 自动提交表单
    const form = tempDiv.querySelector('form');
    if (form) {
      form.submit();
    }
  } catch (error) {
    console.error('支付请求出错:', error);
  }
})


</script>